put editString("findNth", background field "A", cd fld what, cd fld whichOne) into loc
put "The " & cd fld whichOne & " occurance of " "e& char 1 to 1 of cd fld what "e& " is at character position " & loc into fld b
select char loc to loc of bkgnd fld a
end mouseUp
-- part 2 (field)
-- low flags: 00
-- high flags: 0002
-- rect: left=323 top=214 right=231 bottom=354
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 97
-- text size: 9
-- style flags: 0
-- line height: 12
-- part name: what
-- part 3 (field)
-- low flags: 00
-- high flags: 0002
-- rect: left=402 top=214 right=231 bottom=440
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 97
-- text size: 9
-- style flags: 0
-- line height: 12
-- part name: whichOne
-- part contents for background part 1
----- text -----
findNth
-- part contents for background part 2
----- text -----
findNth will return the character position of the Nth occurance of a specific character within a block of text. The maximum size of the text (or data holder) is 30000 bytes.
-- part contents for background part 3
----- text -----
editString("findNth", source, character, Nth)
• source is the input text
• character is the character to search for
• Nth is the sequence number of occurances of character in source
put editString("findNth", field "A", ":", 3) into field "B" will return the character position of the third colon in field "A". If the number to find is greater than the number of occurances then it will return count. If the number to find is less than or equal to zero it will return zero.
-- part contents for background part 4
----- text -----
My Hard Disk:HyperCard:Super Stuff:My Stuff:Your Stuff
-- part contents for card part 2
----- text -----
:
-- part contents for card part 3
----- text -----
3
-- part contents for background part 5
----- text -----
The 3 occurance of ":" is at character position 35